package com.honey.standard.writer.io;

import java.io.File;

/**
 * 验证文件存储,文件验证通过覆盖文件,如果验证失败使用备份的方式生成文件.
 * @author Administrator
 *
 */
class CheckingAndMultiStorage extends Storage {

	public CheckingAndMultiStorage(File source, boolean checked) {
		super(source, checked);
	}

	public CheckingAndMultiStorage(File source, String charset, boolean checked) {
		super(source, charset, checked);
	}
	
	public CheckingAndMultiStorage(String source, String charset, boolean checked) {
		super(source, charset, checked);
	}

	@Override
	protected void setSource(File source) {
		if( !checked ){
			if( source.exists() ){
				source =IoUtility.uniqueFile(source.getParentFile(), source.getName());
			}
		}
		super.setSource(source);
	}
	
	@Override
	public boolean supportWrite() {
		return true;
	}
}
